home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / t_os / wstype / source / wstype.c < prev   
C/C++ Source or Header  |  1991-10-18  |  15KB  |  692 lines

  1. /***   [wstype.c]
  2. *
  3. *    メイン        (C)ささがわ
  4. *
  5. *    For GNU C Compiler (GCC)   Version 1.39
  6. *
  7. ***/
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <mos.h>
  12. #include <kyb.h>
  13. #include <bios.h>
  14. #include "graph.h"
  15. #include "optparse.h"
  16. #include "dropdm.h"
  17. #include "icn.h"
  18. #include "windmgr.h"
  19. #include "beep.h"
  20. #include "others.h"
  21. #include "backg.h"
  22. #include "window.h"
  23. #include "txwind.h"
  24. #include "disp.h"
  25.  
  26. #define WH_MENU        0
  27. #define WH_HELP        1
  28. #define WH_EXIT        2
  29. #define WH_TITLE    3
  30. #define WH_BOX        4
  31. #define WH_OTHER    5
  32.  
  33. int    PAL_Black = 3;
  34. int    PAL_Button = 11;
  35. int PAL_Back = 7;
  36. int PAL_MOJI = 3;
  37. static int    wx, wy;
  38. static char    titl[12800];
  39.  
  40. extern void    Errhdl(void);
  41. extern void    CtrlC_ignore(void);
  42. extern int    WIND_callWin(int, int);
  43. extern void    WIND_filesel_init(void);
  44. extern void    WIND_eyes(void);
  45. extern void    WIND_clock(void);
  46. extern void    WIND_schroll(void);
  47. extern void    WIND_help(void);
  48. extern void    SCR_init(void);
  49.  
  50. static int    SUB_exit(void);
  51. static void    SUB_help(void);
  52. static void    MENU_Win(int);
  53. static void    MENU_Setting(int);
  54. static void    MENU_Others(int);
  55. static void    CloseWinall(void);
  56. static void    CallWin(void);
  57. static void    PutWinorder(void);
  58. static void    OpenWin_init(void);
  59. static void    ScreenInitialize(void);
  60. static void    ScreenDisposeof(void);
  61. static void    Set_palette(void);
  62. static int    Menubar(int *, int *);
  63. static int    Where(int, int);
  64. static void    OpenWin(void);
  65. static void    Title_open(void);
  66. static void    Title_close(void);
  67. static void    SUB_move_scope(int, int);
  68. static void    SUB_Window(int, int);
  69. static void    MoveScope_start(void);
  70. static void    MoveScope_end(int, int);
  71. static void    activeWin(int, int, int);
  72.  
  73. void main(int argc, char *argv[]) {
  74.     int        ret = 0;
  75.     
  76.     fprintf(stderr, "WSType  Version 1.0   (C)ささがわ  Aug. 1991\n");
  77.     
  78.     CtrlC_ignore();
  79.     Errhdl();
  80.     ScreenInitialize();
  81.     
  82.     OPT_init(argc, argv);
  83.     BEP_init();
  84.     BACKG_init();
  85.     WIND_filesel_init();
  86.     DSP_init();
  87.     SCR_init();
  88.     
  89.     MOS_disp(0);
  90.     BACKG_draw(0, 0);
  91.     Title_open();
  92.     MOS_disp(1);
  93.     CLOCK(1);
  94.     
  95.     OpenWin_init();
  96.     
  97.     while (!ret) {
  98.         char    mb;
  99.         int        mx, my, d;
  100.         
  101.         CLOCK(0);
  102.         if (MOS_rdpos(&mb, &mx, &my), !(mb & 1))
  103.             continue;
  104.         MOS_rdon(0, &mb, &d, &d, &d);
  105.         
  106.         switch (Where(mx, my)) {
  107.             case WH_EXIT:    ret = SUB_exit();    break;
  108.             case WH_HELP:    SUB_help();        break;
  109.             case WH_MENU:
  110.                 if (!Menubar(&mx, &my))    break;
  111.                 switch (mx) {
  112.                     case 0:        MENU_Win(my);        break;
  113.                     case 1:        MENU_Setting(my);    break;
  114.                     default:    MENU_Others(my);    break;
  115.                 }
  116.                 break;
  117.             case WH_BOX:    SUB_move_scope(mx, my);    break;
  118.             case WH_OTHER:    SUB_Window(mx, my);        break;
  119.             default:    while (MOS_rdpos(&mb, &mx, &my), mb & 1);    break;
  120.         }
  121.     }
  122.     
  123.     ScreenDisposeof();
  124.     if (OPT_Cons())    MOS_screenterm(EGB_work);
  125. }
  126.  
  127. static int SUB_exit(void) {
  128.     int        r, cw;
  129.     static const char    *a[] = {
  130.         "WSTypeを終了します",
  131.         ""
  132.     };
  133.     
  134.     if (!Button(wx + 603, wy + 3, wx + 634, wy + 34))
  135.         return 0;
  136.     
  137.     cw = WMGR_cWind();
  138.     WMGR_close();
  139.     Xpage(0, wx, wy);
  140.     r = WIND_confirm("終  了", a);
  141.     Xpage(1, wx, wy);
  142.     EGB_rev(1, wx + 603, wy + 3, wx + 634, wy + 34);
  143.     if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  144.     
  145.     return r;
  146. }
  147.  
  148. static void SUB_help(void) {
  149.     int        cw;
  150.     
  151.     if (!Button(wx + 563, wy + 3, wx + 594, wy + 34))
  152.         return;
  153.     
  154.     cw = WMGR_cWind();
  155.     WMGR_close();
  156.     Xpage(0, wx, wy);
  157.     WIND_help();
  158.     Xpage(1, wx, wy);
  159.     EGB_rev(1, wx + 563, wy + 3, wx + 594, wy + 34);
  160.     if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  161. }
  162.  
  163. static void MENU_Win(int a) {
  164.     switch (a) {
  165.         case 0:        OpenWin();    break;
  166.         case 1:        CallWin();    break;
  167.         case 2:        PutWinorder();    break;
  168.         default:    CloseWinall();    break;
  169.     }
  170. }
  171.  
  172. static void MENU_Setting(int a) {
  173.     int        cw;
  174.     
  175.     cw = WMGR_cWind();
  176.     WMGR_close();
  177.     Xpage(0, wx, wy);
  178.     switch (a) {
  179.         case 0:    DSP_change();    break;
  180.         case 1:    WIND_schroll();    break;
  181.         default:    WIND_beep();    break;
  182.     }
  183.     Xpage(1, wx, wy);
  184.     if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  185. }
  186.  
  187. static void MENU_Others(int a) {
  188.     int        cw;
  189.     
  190.     cw = WMGR_cWind();
  191.     WMGR_close();
  192.     Xpage(0, wx, wy);
  193.     switch (a) {
  194.         case 0:    WIND_error(5, NULL);    break;
  195.         case 1:    WIND_clock();        break;
  196.         default:    WIND_eyes();    break;
  197.     }
  198.     Xpage(1, wx, wy);
  199.     if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  200. }
  201.  
  202. static void CloseWinall(void) {
  203.     int        r, cw;
  204.     static const char    *a[] = {
  205.         "     すべて閉じます",
  206.         ""
  207.     };
  208.     
  209.     cw = WMGR_cWind();
  210.     WMGR_close();
  211.     Xpage(0, wx, wy);
  212.     r = WIND_confirm("ウィンドウ", a);
  213.     Xpage(1, wx, wy);
  214.     if (!r) {
  215.         if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  216.         return;
  217.     }
  218.     
  219.     while (WMGR_nWind() > 0)    WMGR_unregi(0);
  220.     
  221.     MOS_disp(0);
  222.     EGB_actPage(0);
  223.     EGB_cls(0);
  224.     EGB_Hscrl(0, 0);
  225.     BACKG_draw(0, 0);
  226.     
  227.     EGB_actPage(1);
  228.     Title_close();
  229.     EGB_cls(0);
  230.     BACKG_draw(wx, wy);
  231.     Title_open();
  232.     MOS_disp(1);
  233.     CLOCK(1);
  234. }
  235.  
  236. static void PutWinorder(void) {
  237.     int        i, n, r, cw;
  238.     static const char    *a[] = {
  239.         "       整頓します",
  240.         ""
  241.     };
  242.     
  243.     cw = WMGR_cWind();
  244.     WMGR_close();
  245.     Xpage(0, wx, wy);
  246.     r = WIND_confirm("ウィンドウ", a);
  247.     Xpage(1, wx, wy);
  248.     if (!r) {
  249.         if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  250.         return;
  251.     }
  252.     
  253.     MOS_disp(0);
  254.     EGB_actPage(0);
  255.     EGB_cls(0);
  256.     EGB_Hscrl(0, 0);
  257.     BACKG_draw(0, 0);
  258.     
  259.     EGB_actPage(1);
  260.     Title_close();
  261.     EGB_cls(0);
  262.     BACKG_draw(wx, wy);
  263.     for (i = 0, n = WMGR_nWind(); i < n; i++) {
  264.         int        a;
  265.         struct RECT    c;
  266.         struct txinfo_t    *inf;
  267.         
  268.         inf = WMGR_inf(i);
  269.         WMGR_place(i, n, wx, wy, &c);
  270.         WMGR_change(i, &c);
  271.         a = (c.x2 - c.x1 - 31) / (inf->fontx / 2);
  272.         if (inf->lgcolw)
  273.             BMGR_change(a, inf->tab, &inf->file, &inf->line);
  274.         else {
  275.             if (inf->col >= (inf->lgcolw ? a : inf->lgcol))
  276.                 inf->col = (inf->lgcolw ? a : inf->lgcol) - 1;
  277.         }
  278.         WMGR_draw(i);
  279.     }
  280.     Title_open();
  281.     MOS_disp(1);
  282.     CLOCK(1);
  283. }
  284.  
  285. static void CallWin(void) {
  286.     int        r, cw, mx, my;
  287.     char    mb;
  288.     
  289.     cw = WMGR_cWind();
  290.     WMGR_close();
  291.     Xpage(0, wx, wy);
  292.     r = WIND_callWin(wx, wy);
  293.     Xpage(1, wx, wy);
  294.     if (r < 0) {
  295.         if (cw >= 0)
  296.             WMGR_open(0, cw, wx, wy);
  297.         return;
  298.     }
  299.     
  300.     MOS_rdpos(&mb, &mx, &my);
  301.     activeWin(r, mx - wx, my - wy);
  302. }
  303.  
  304. static void OpenWin_init(void) {
  305.     int        i, nt;
  306.     struct RECT    p, af1;
  307.     
  308.     ICN_mos(1);
  309.     af1.x1 = wx + 319;    af1.y1 = wy + 259;
  310.     af1.x2 = wx + 320;    af1.y2 = wy + 260;
  311.     p.x1 = wx;    p.y1 = wy + 40;
  312.     p.x2 = wx + 639;    p.y2 = wy + 479;
  313.     nt = OPT_txt_n();
  314.     
  315.     for (i = 0; i < nt; i++) {
  316.         int        r;
  317.         const char    *fname;
  318.         struct RECT    c, af2;
  319.         
  320.         WMGR_place(i, nt, wx, wy, &c);
  321.         af2 = c;
  322.         afterImage(&af1, &af2);
  323.         
  324.         fname = OPT_txt();
  325.         r = WMGR_regi(0, fname, &c, nt <= 8 ? &p : &c);
  326.         if (r >= 0)
  327.             WMGR_draw(r);
  328.         else {
  329.             Xpage(0, wx, wy);
  330.             switch (r) {
  331.                 case -1:    WIND_error(1, NULL);    break;
  332.                 case -2:    WIND_error(0, fname);    break;
  333.                 default:    WIND_error(2, NULL);    break;
  334.             }
  335.             Xpage(1, wx, wy);
  336.             MOS_disp(0);
  337.             EGB_writeMode(EGB_work, 4);
  338.             EGB_box(af2.x1, af2.y1, af2.x2, af2.y2, 15);
  339.             EGB_writeMode(EGB_work, 0);
  340.             MOS_disp(1);
  341.             if (r != -2)    break;
  342.         }
  343.     }
  344.     ICN_mos(0);
  345. }
  346.  
  347. static void OpenWin(void) {
  348.     int        cw, w, ret;
  349.     char    path[85];
  350.     struct RECT    c, p, z;
  351.     
  352.     cw = WMGR_cWind();
  353.     WMGR_close();
  354.     Xpage(0, wx, wy);
  355.     ret = WIND_filesel("ウィンドウ・開く", path);
  356.     Xpage(1, wx, wy);
  357.     
  358.     if (ret != 1) {
  359.         if (cw >= 0)    WMGR_open(0, cw, wx, wy);
  360.         return;
  361.     }
  362.     
  363.     if (WMGR_nWind() == 0) {
  364.         c.x1 = wx;            c.y1 = wy + 40;
  365.         c.x2 = wx + 639;    c.y2 = wy + 479;
  366.         p.x1 = wx + 160;    p.y1 = wy + 150;
  367.         p.x2 = wx + 479;    p.y2 = wy + 369;
  368.     } else {
  369.         c.x1 = wx + 160;    c.y1 = wy + 150;
  370.         c.x2 = wx + 479;    c.y2 = wy + 369;
  371.         p.x1 = wx;            p.y1 = wy + 40;
  372.         p.x2 = wx + 639;    p.y2 = wy + 479;
  373.     }
  374.     
  375.     z.x1 = wx + 319;    z.y1 = wy + 259;
  376.     z.x2 = wx + 320;    z.y2 = wy + 260;
  377.     afterImage(&z, &c);
  378.     
  379.     w = WMGR_regi(0, path, &c, &p);
  380.     if (w >= 0) {
  381.         WMGR_open(1, w, wx, wy);
  382.     } else {
  383.         Xpage(0, wx, wy);
  384.         switch (w) {
  385.             case -1:    WIND_error(1, NULL);    break;
  386.             case -2:    WIND_error(0, path);    break;
  387.             default:    WIND_error(2, NULL);    break;
  388.         }
  389.         Xpage(1, wx, wy);
  390.         MOS_disp(0);
  391.         EGB_writeMode(EGB_work, 4);
  392.         EGB_box(c.x1, c.y1, c.x2, c.y2, 15);
  393.         EGB_writeMode(EGB_work, 0);
  394.         MOS_disp(1);
  395.     }
  396. }
  397.  
  398. static void ScreenInitialize(void) {
  399.     static char    mwork[4 * 1024];
  400.     static char    swork[16 * 1024];
  401.     
  402.     KYB_init();
  403.     KYB_clic(1);
  404.     
  405.     EGB_int();
  406.     EGB_resolution(EGB_work, 0, 3);
  407.     EGB_resolution(EGB_work, 1, 3);
  408.     EGB_displayPage(EGB_work, 1, 3);
  409.     
  410.     SND_init(swork);
  411.     SND_pcm_mode_set(1);
  412.     
  413.     MOS_start(mwork, 4 * 1024);
  414.     MOS_resolution(0, 3);
  415.     MOS_resolution(1, 3);
  416.     MOS_writePage(1);
  417.     MOS_horizon(0, 639);
  418.     MOS_vertical(0, 479);
  419.     ICN_mos(0);
  420.     
  421.     EGB_actPage(0);
  422.     Set_palette();
  423.     EGB_actPage(1);
  424.     Set_palette();
  425.     
  426.     MOS_setpos(320, 240);
  427.     MOS_disp(1);
  428. }
  429.  
  430. static void Title_open(void) {
  431.     int        i;
  432.     
  433.     EGB_get(titl, wx, wy, wx + 639, wy + 39);
  434.     EGB_boxf(wx, wy, wx + 639, wy + 39, 13, 13);
  435.     for (i = 0; i < 2; i++)
  436.         EGB_str2(" WSType   Version 1.0", wx + 40 + i, wy + 16, PAL_Black);
  437.     
  438.     EGB_boxf(wx + 4, wy + 4, wx + 37, wy + 37, PAL_Black, PAL_Black);
  439.     EGB_boxf(wx + 2, wy + 2, wx + 35, wy + 35, PAL_Black, 15);
  440.     ICN_put(3, wx + 3, wy + 3, PAL_Black);
  441.     
  442.     EGB_boxf(wx + 42, wy + 19, wx + 299, wy + 38, PAL_Black, PAL_Black);
  443.     EGB_boxf(wx + 40, wy + 17, wx + 297, wy + 36, PAL_Black, 15);
  444.     EGB_str2(" ウィンドウ ", wx + 41, wy + 34, PAL_Black);
  445.     EGB_str2(" 設    定 ", wx + 137, wy + 34, PAL_Black);
  446.     EGB_str2(" そ の 他 ", wx + 217, wy + 34, PAL_Black);
  447.     
  448.     EGB_boxf(wx + 564, wy + 4, wx + 597, wy + 37, PAL_Black, PAL_Black);
  449.     EGB_boxf(wx + 562, wy + 2, wx + 595, wy + 35, PAL_Black, 15);
  450.     ICN_put(98, wx + 563, wy + 3, PAL_Black);
  451.     EGB_boxf(wx + 604, wy + 4, wx + 637, wy + 37, PAL_Black, PAL_Black);
  452.     EGB_boxf(wx + 602, wy + 2, wx + 635, wy + 35, PAL_Black, 15);
  453.     ICN_put(126, wx + 603, wy + 3, PAL_Black);
  454. }
  455.  
  456. static void Title_close(void) {
  457.     EGB_put(0, titl, wx, wy, wx + 639, wy + 39);
  458. }
  459.  
  460. static void ScreenDisposeof(void) {
  461.     MOS_end();
  462.     SND_end();
  463.     EGB_displayPage(EGB_work, 0, 0);
  464. }
  465.  
  466. static void Set_palette(void) {
  467.     EGB_pal(3, 0, 0, 0, 1);
  468.     EGB_pal(4, 112, 0, 0, 1);
  469.     EGB_pal(6, 112, 160, 64, 1);
  470.     EGB_pal(7, 181, 181, 181, 1);
  471.     EGB_pal(11, 128, 128, 128, 1);
  472.     EGB_pal(13, 172, 50, 223, 1);
  473. }
  474.  
  475. static int Menubar(int *x, int *y) {
  476.     struct dropdm_t    dp;
  477.     struct menu_t    m[3];
  478.     static const char    *a[] = {
  479.         " 開  く       ",
  480.         " 呼び出し     ",
  481.         " 整理整頓     ",
  482.         " ────── ",
  483.         " すべて閉じる ",
  484.         NULL
  485.     }, *b[] = {
  486.         " 表示方法   ",
  487.         " スクロール ",
  488.         " 警 告 音   ",
  489.         NULL
  490.     }, *c[] = {
  491.         " CDプレイヤー ",
  492.         " Clock     ",
  493.         " Eyes       ",
  494.         NULL
  495.     };
  496.     char    am[] = {
  497.         0, 0, 0, 0, 0
  498.     }, bm[] = {
  499.         0, 0, 0
  500.     }, cm[] = {
  501.         0, 0, 0
  502.     };
  503.     
  504.     if (WMGR_nWind() == 0) {
  505.         am[1] = 1;    am[2] = 1;    am[4] = 1;
  506.     }
  507.     
  508.     m[0].xt = wx + 41;    m[0].wt = 96;
  509.     m[0].xm = m[0].xt;    m[0].wm = 14;
  510.     m[0].name = a;        m[0].mask = am;
  511.     m[1].xt = wx + 137;    m[1].wt = 80;
  512.     m[1].xm = m[1].xt;    m[1].wm = 12;
  513.     m[1].name = b;        m[1].mask = bm;
  514.     m[2].xt = wx + 217;    m[2].wt = 80;
  515.     m[2].xm = m[2].xt;    m[2].wm = 16;
  516.     m[2].name = c;        m[2].mask = cm;
  517.     
  518.     dp.ntitle = 3;    dp.yt1 = wy + 18;
  519.     dp.yt2 = dp.yt1 + 17;    dp.ym = dp.yt1 + 24;
  520.     dp.m = m;    dp.shadow = 1;
  521.     
  522.     return DRPDM_main(x, y, &dp);
  523. }
  524.  
  525. static int Where(int x, int y) {
  526.     int        wh;
  527.     
  528.     x -= wx;
  529.     y -= wy;
  530.     if (40 < x && x < 297 && 17 < y && y < 36)
  531.         wh = WH_MENU;
  532.     else if (562 < x && x < 595 && 2 < y && y < 35)
  533.         wh = WH_HELP;
  534.     else if (602 < x && x < 635 && 2 < y && y < 35)
  535.         wh = WH_EXIT;
  536.     else if (2 < x && x < 35 && 2 < y && y < 35)
  537.         wh = WH_BOX;
  538.     else if (0 < x && x < 640 && 0 < y && y < 40)
  539.         wh = WH_TITLE;
  540.     else
  541.         wh = WH_OTHER;
  542.     
  543.     return wh;
  544. }
  545.  
  546. static void MoveScope_start(void) {
  547.     int        i, n;
  548.     struct RECT    xy;
  549.     static char    mask[65536];
  550.     
  551.     WMGR_close();
  552.     MOS_disp(0);
  553.     EGB_actPage(0);
  554.     EGB_cls(0);
  555.     EGB_Hscrl(0, 0);
  556.     BACKG_draw(0, 0);
  557.     
  558.     EGB_actPage(1);
  559.     Title_close();
  560.     EGB_maskRegion(EGB_work, mask);
  561.     EGB_mask(EGB_work, 0x02);
  562.     EGB_writeMode(EGB_work, 13);
  563.     
  564.     for (i = 0, n = WMGR_nWind(); i < n; i++) {
  565.         WMGR_cord(i, &xy);
  566.         EGB_boxf(xy.x1, xy.y1, xy.x2, xy.y2, 0, 0);
  567.     }
  568.     
  569.     EGB_mask(EGB_work, 0x80);
  570.     EGB_writeMode(EGB_work, 0);
  571.     EGB_boxf(wx, wy, wx + 639, wy + 479, 0, 0);
  572. }
  573.  
  574. static void MoveScope_end(int x, int y) {
  575.     BACKG_draw(wx, wy);
  576.     EGB_mask(EGB_work, 0);
  577.     MOS_horizon(wx, wx + 639);
  578.     MOS_vertical(wy, wy + 479);
  579.     if (x >= 0 && y >= 0)
  580.         MOS_setpos(wx + x, wy + y);
  581.     Title_open();
  582.     MOS_disp(1);
  583.     CLOCK(1);
  584. }
  585.  
  586. static void SUB_move_scope(int xx, int yy) {
  587.     int        mx, my;
  588.     char    mb;
  589.     
  590.     MoveScope_start();
  591.     MOS_horizon(xx - wx, 1024 - (wx + 640 - xx));
  592.     MOS_vertical(yy - wy, 512 - (wy + 480 - yy));
  593.     do {
  594.         MOS_rdpos(&mb, &mx, &my);
  595.         EGB_Hscrl(mx - (xx - wx), my - (yy - wy));
  596.     } while (mb & 1);
  597.     wx = mx - (xx - wx);
  598.     wy = my - (yy - wy);
  599.     MoveScope_end(-1, -1);
  600. }
  601.  
  602. static void SUB_Window(int mx, int my) {
  603.     int        w;
  604.     struct RECT    xy;
  605.     
  606.     TIMER_set(40);
  607.     if ((w = WMGR_onWind(mx, my)) < 0)
  608.         return;
  609.     
  610.     WMGR_cord(w, &xy);
  611.     if (xy.x1 < wx || wx + 639 < xy.x2 || xy.y1 < wy + 40 || wy + 479 < xy.y2) {
  612.         int        a, i, x, y;
  613.         char    mb;
  614.         
  615.         if (MOS_rdon(0, &mb, &a, &x, &y), !a) {
  616.             while (MOS_rdon(0, &mb, &a, &x, &y), i = TIMER(), !a && !i);
  617.             if (i)    return;
  618.         }
  619.         if (w != WMGR_onWind(x, y))    return;
  620.         
  621.         activeWin(w, -1, -1);
  622.     } else {
  623.         activeWin(w, -1, -1);
  624.         WMGR_main(mx, my);
  625.     }
  626. }
  627.  
  628. static void activeWin(int w, int mx, int my) {
  629.     int        a, i;
  630.     struct RECT    xy;
  631.     
  632.     WMGR_cord(w, &xy);
  633.     if (xy.x1 < wx || wx + 639 < xy.x2 || xy.y1 < wy + 40 || wy + 479 < xy.y2) {
  634.         MoveScope_start();
  635.         
  636.         if ((a = xy.x1 - wx) >= 0) {
  637.             if ((a = xy.x2 - (wx + 639)) <= 0)
  638.                 a = 0;
  639.         }
  640.         i = a > 0 ? 10 : -10;
  641.         while (abs(i) < abs(a)) {
  642.             EGB_Hscrl(wx + i, wy);
  643.             i += a > 0 ? 10 : -10;
  644.         }
  645.         EGB_Hscrl(wx += a, wy);
  646.         
  647.         if ((a = xy.y1 - (wy + 40)) >= 0) {
  648.             if ((a = xy.y2 - (wy + 479)) <= 0)
  649.                 a = 0;
  650.         }
  651.         i = a > 0 ? 10 : -10;
  652.         while (abs(i) < abs(a)) {
  653.             EGB_Hscrl(wx, wy + i);
  654.             i += a > 0 ? 10 : -10;
  655.         }
  656.         EGB_Hscrl(wx, wy += a);
  657.         
  658.         MoveScope_end(mx, my);
  659.     }
  660.     WMGR_open(0, w, wx, wy);
  661. }
  662.  
  663. void CLOCK(int m) {
  664.     int        i = 0, p;
  665.     unsigned char    buf[20];
  666.     struct calender_t    cal;
  667.     static struct calender_t    pcal;
  668.     const static char    *week[] = {
  669.         "日", "月", "火", "水", "木", "金", "土"
  670.     }, *tzone[] = {
  671.         "深夜", "早朝", " 朝 ", "午前", " 昼 ", "午後", "夕方", " 夜 "
  672.     }, tz[] = {
  673.         3, 6, 9, 11, 13, 15, 18, 23
  674.     };
  675.     
  676.     _bios_timeofday(_TIME_GETCLOCK, &cal);
  677.     if (!m && pcal.hour == cal.hour && pcal.minute == cal.minute)
  678.         return;
  679.     
  680.     MOS_disp(0);
  681.     p = EGB_readactPage();
  682.     EGB_actPage(1);
  683.     sprintf((char *)buf, "%4u-%2u-%2u.%s", cal.year, cal.month, cal.day, week[cal.week]);
  684.     EGB_str3((char *)buf, wx + 410, wy + 17, PAL_Black, 13);
  685.     while (cal.hour > tz[i])    i++;
  686.     sprintf((char *)buf, "  %2u:%2u %s", cal.hour, cal.minute, tzone[i]);
  687.     EGB_str3((char *)buf, wx + 410, wy + 37, PAL_Black, 13);
  688.     EGB_actPage(p);
  689.     MOS_disp(1);
  690.     pcal = cal;
  691. }
  692.